home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.modula3,comp.lang.c++,comp.lang.java
- Path: beaver.cs.washington.edu!whsieh
- From: whsieh@porky-pig.lcs.mit.edu (Wilson Hsieh)
- Subject: Re: Java closer to Modula-3 than to C++
- Sender: news@beaver.cs.washington.edu (USENET News System)
- Organization: Department of Computer Science and Engineering, UW
- Message-ID: <WHSIEH.96Feb29123728@porky-pig.lcs.mit.edu>
- References: <31308FE2.167E@sophia.inria.fr> <1996Feb26.192508.2614@friend.kastle.com>
- <DAGENAIS.96Feb29113254@hagen.vlsi.polymtl.ca>
- In-Reply-To: dagenais@hagen.vlsi.polymtl.ca's message of 29 Feb 96 11:32:54
- X-Nntp-Posting-Host: porky-pig.cs.washington.edu
- Date: Thu, 29 Feb 1996 20:37:28 GMT
-
-
-
-
- We (the SPIN group at UW) have noticed some potential alignment
- problems in going between M3 and C. These problems are very
- implementation-dependent, but you probably should be aware of them.
- SPIN currently runs DEC SRC M3 on Alphas, but I'm sure similar issues
- arise on other platforms. Take the apparently equivalent types:
-
- struct foo {
- int x:8;
- int y:8;
- int z:8;
- };
-
- TYPE FOO = RECORD
- x: BITS 8 FOR [0..255];
- y: BITS 8 FOR [0..255];
- z: BITS 8 FOR [0..255];
- END
-
- The C compilers on the Alpha that we have (DEC cc and gcc), and I
- would suspect most C compilers, pad the C structure out to 32 bits.
- The DEC SRC M3 compiler does not pad out the RECORD. There are
- several possible sources of problems here in passing a REF FOO type
- out to C, which expects a struct foo, which boil down to the fact that
- the C compilers assume that a struct foo is 32-bit aligned, whereas a
- FOO need not be. (For example, an ARRAY OF FOO is not the same as a C
- array of struct foo!)
-
- Also, note that the DEC SRC M3 compiler is not strictly less
- restrictive than the C compilers in terms of alignment, so problems
- can arise when going from C to M3 as well. The M3 compiler rounds up
- alignment, as long as padding is not required. (We first noticed
- these issues when dealing with trying to VIEW network packet headers,
- by the way.) For example,
-
- struct bar {
- int x:16;
- int y:16;
- int z:16;
- int a:16;
- };
-
- TYPE BAR = RECORD
- x: BITS 16 FOR [0..16_ffff];
- y: BITS 16 FOR [0..16_ffff];
- z: BITS 16 FOR [0..16_ffff];
- a: BITS 16 FOR [0..16_ffff];
- END
-
- Our C compilers again assume that a struct bar is 32-bit aligned,
- whereas the DEC SRC M3 compiler boosts the alignment of BAR such that
- every BAR is 64-bit aligned.
- - Wilson
-
-
- In article <DAGENAIS.96Feb29113254@hagen.vlsi.polymtl.ca> dagenais@hagen.vlsi.polymtl.ca (Michel Dagenais) writes:
-
- In article <1996Feb26.192508.2614@friend.kastle.com> rich@kastle.com (Richard Krehbiel) writes:
-
- Oh, I think it's clear that C++ gets it's success from C. C #includes
- and libraries can (almost always) be called upon in C++ programs.
- Nothing like that can be said of Modula-3 or Java.
-
- Well, too bad i did not know i could not do it. I have called X libraries,
- unix system calls, the gnu dbm library, ODBC drivers... from Modula-3 without
- problem.
-